function myNew(fn) {
    let args = Array.prototype.slice.call(arguments,1)
    let obj = Object.create(fn.prototype)
    let result = fn.apply(obj,args)
    return result instanceof Object? result: obj
}

function foo(a,b) {
    this.a = a
    this.b = b
}

let obj = myNew(foo,1,2)
// let obj = new foo(1,2)
console.log(obj.a)